package org.farms.algo.helpers;

public class Pair<F, S> {
	private F first;
	private S second;

	@Override
	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (obj == null || obj.getClass() != this.getClass()) {
			return false;
		}
		
		@SuppressWarnings("unchecked")
		Pair<F, S> anotherPair = (Pair<F, S>)obj;
		
		return ((this.first == anotherPair.first) ||
					(first != null && first.equals(anotherPair.first))) &&
			   ((this.second == anotherPair.second) ||
					(second != null && second.equals(anotherPair.second)));
	}
	
	@Override
	public int hashCode() {
		return (this.first.hashCode() * 100 + this.second.hashCode());
	}
	
	public Pair(F first, S second) {
		this.first = first;
		this.second = second;
	}
	
	public F getFirst() {
		return first;
	}
	public void setFirst(F first) {
		this.first = first;
	}
	public S getSecond() {
		return second;
	}
	public void setSecond(S second) {
		this.second = second;
	}
}
